#ifndef _OI_LT360BASE_TOOL_HPP_
#define _OI_LT360BASE_TOOL_HPP_

#include "OiLT360Base.hpp"
#include "OiDataStructure.hpp"
#include "OiDataViewer.hpp"

namespace Oi
{
    namespace Appl
    {
        enum DisplayMode
        {
            DETAILED = 0,
            SIMPLE,
            DETAILED_GRAPH,
            SIMPLE_GRAPH,
            GRAPH
        };

        class TestTool : public QGraphicsTextItem
        {
            Q_OBJECT
        public:
            TestTool(QGraphicsItem*);
            ~TestTool()
            {
            }
        
        signals:
            void requestContextMenu(QPoint);

        protected:
            void contextMenuEvent(QGraphicsSceneContextMenuEvent* event);

        };

        class OI_LT360BASE_API Tool : public QGraphicsObject
        {
            Q_OBJECT

        public:
            Tool(QGraphicsItem *parent = Q_NULLPTR, QtCharts::QChart* chart = Q_NULLPTR, qreal x = 0, qreal y = 0, qreal width = 100, qreal height = 50);
            ~Tool();
            
        public:
            void drawLine(QPainter *painter, const QPointF &startPoint, const QPointF &endPoint, QColor color, qreal width);
            void drawArrow(QPainter * painter, QColor color, const QPointF & arrowTip, const QPointF & arrowDirection, const double & angle, const double & length);
            void paint(QPainter *painter, const QStyleOptionGraphicsItem *o, QWidget *w);
            void updateResult(double result);
            void setOutput(LTBase::AlgoOutput& output);
            void updateLatchPoint();
            QPointF latchPoint();
            void setFontSize(int fontSize);
            //void setDisplayModeSimple(bool flag);
            //bool displayModeSimple();
            void setDisplayMode(DisplayMode displayMode);
            DisplayMode displayMode();

            bool hasDetailedLabel();

            double min();
            double max();
            void setDataViewer(DataViewer* viewer);
            DataViewer* dataViewer();

            QString name();
            void setName(QString name);

            void updateDataviewer(LTBase::AlgoOutput& output);
            void setRect(qreal x = 0, qreal y = 0, qreal width = 100, qreal height = 50);

            void hideDataViewer();
            void showDataViewer();
        public slots:
            void requestContextMenu(QPoint);
            void manualUpdate(QPoint);

        signals:
            void settingChanged();

        protected:
            void mousePressEvent(QGraphicsSceneMouseEvent* event);
            void contextMenuEvent(QGraphicsSceneContextMenuEvent* event);
            QRectF boundingRect() const;

        private:
            OI_DISABLE_COPY(Tool);
            OI_DECLARE_IMPL(Tool);

        };
    }
}



#endif